package com.example.definedview;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.View;

import com.example.definedview.databinding.ActivityTemperatureBinding;

public class TemperatureActivity extends AppCompatActivity {
    ActivityTemperatureBinding activityTemperatureBinding;
    float temperature;

    //温度计
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_temperature);
        activityTemperatureBinding = DataBindingUtil.setContentView(this, R.layout.activity_temperature);
        temperature = (float)25.0;
        activityTemperatureBinding.thermometerView.setCurValue(temperature);

        activityTemperatureBinding.add10.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                temperature +=10;
                activityTemperatureBinding.thermometerView.setValueAndStartAnim(temperature);
            }
        });

        activityTemperatureBinding.minus10.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                temperature -= 10;
                activityTemperatureBinding.thermometerView.setValueAndStartAnim(temperature);
            }
        });
    }
}
